/*************************************************************************
	> File Name: P1317.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-02-11 11:08:22
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 10000
int arr[MAX_N + 5];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int k = 1, cnt = 0;
    while (k <= n) {
        while (k <= n && arr[k] <= arr[k - 1]) k++;
        while (k <= n && arr[k] >= arr[k - 1]) k++;
        cnt += 1;
    }
    cout << cnt - 2 << endl;
    return 0;
}
